package com.csq.manager.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.csq.manager.pojo.Account;
import com.csq.manager.service.AccountService;

@Controller
@RequestMapping("/manager/account")
public class AccountController {
	
	@Autowired
	private AccountService accountService;
	
	@RequestMapping(value="/{userId}")
	@ResponseBody
	public Account getAccountByID(@PathVariable Integer userId) {
		System.out.println("sasas");
		Account account = accountService.getAccountByID(userId);
		
		System.out.println("sasas");
		return account;
	}
	
	
	@RequestMapping(value="/list/type/{typeId}")
	public String getAllAccounts(HttpServletRequest request, @PathVariable Integer typeId) {
		List<Account> accountList = accountService.getAllAccountList(typeId);
		request.setAttribute("accountList", accountList);
		System.out.println("/list/type/" + typeId);
		return "/manager/user/account";
	}
}
